package com.chenjj.bigdata.spark.scala.sparkdemo1

import org.apache.spark.SparkConf
import org.apache.spark.sql.{SQLContext, SparkSession}
import org.apache.spark.streaming.{Seconds, StreamingContext}

object Sparkdemo1Application {

  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf()
          .setAppName("Spark1DemoApplication")
          .setMaster("local")
          .set("spark.testing.memory", "1024000000")

    val ssc = new StreamingContext(sparkConf,Seconds(5))
    ssc.checkpoint("checkpoint/SparkDemo1")

    val sqlContext = SparkSession.builder().config(sparkConf).getOrCreate().sqlContext

    val lines = ssc.socketTextStream("n1",8888)
    lines.foreachRDD(x=> DataProcess.processLine(sqlContext,x))

    ssc.start
    ssc.awaitTermination()

  }
}
